package com.xbs.dao.hitchhiking;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.xbs.dao.conn.BaseDao;
import com.xbs.dao.conn.ParamSet;
import com.xbs.dao.conn.RowDatas;
import com.xbs.entity.CommonOrderEntity;
import com.xbs.entity.OrderMoney;
/**
 * 查看订单详情
 * @author dell
 */
import com.xbs.entity.RentEntity;
import com.xbs.entity.TimeEntity;
public class ChaKanXiangQingDao extends BaseDao {

	private RowDatas<RentEntity> rent;
	private RowDatas<CommonOrderEntity> coe;
	private RowDatas<TimeEntity> time;
	private RowDatas<OrderMoney> om;
	
	
	public ChaKanXiangQingDao() {
		rent = new getRentData();
		coe = new getOrerData();
		time = new getTimeData();
		om = new getMoneyData();
	}

	/**
	 * 1.查看详情，
	 * 有租车人信息表中的姓名，电话
	 * 订单表中车牌号，车型名，订单状态，取车门店，还车门店，备注，应付金额，退还金额
	 * 时间表中的提交时间，付款时间，
	 * 后台获取的时间，订单完成时间，取车时间，还车时间
	 * 金钱表租金，押金，基本保险费，车辆破损费，服务费
	 */
	public RentEntity getRent(String id){
		String sql = "select rent_name,rent_telphone "
				+ " from tb_rent where co_id =?";
		return query(sql, new ParamSet(id), rent);
	}
	
	public TimeEntity getTime(String id){
		String sql = "select  date_format(time_order_pay,'%Y-%m-%d') as paytime"
				+ " from tb_time where time_order_id =?";
		return query(sql, new ParamSet(id), time);
	}
	
	public CommonOrderEntity getOrder(String id){
		String sql = "select co_car_type,co_get_store,"
				+ " co_return_store,co_order_status,co_remark,"
				+ "  co_plan_pay_money,co_return_money "
				+ " from tb_common_order where co_order_kind='顺风车' "
				+ " and co_id=?";
		return query(sql, new ParamSet(id), coe);
	}
	
	public OrderMoney getMoney(String id){
		String sql = "select order_rent_money,"
				+ " order_guarantee_money,order_insurance_money,"
				+ " order_service_money,order_car_damage_money "
				+ " from tb_order_money where order_id =?";
		return query(sql, new ParamSet(id), om);
	}
	
	class getTimeData implements RowDatas<TimeEntity>{

		@Override
		public TimeEntity getRowData(ResultSet rs) throws SQLException {
			TimeEntity time = new TimeEntity();
			//	time.setTime_order_id(rs.getString("time_order_id"));
				time.setTime_order_pay(rs.getTimestamp("paytime"));	
			return time;
		}
		
	}
	
	
	class getRentData implements RowDatas<RentEntity>{

		@Override
		public RentEntity getRowData(ResultSet rs) throws SQLException {
			RentEntity rent = new RentEntity();
			//rent.setCo_id(rs.getString("co_id"));
			rent.setRent_name(rs.getString("rent_name"));
			rent.setRent_telephone(rs.getString("rent_telphone"));
			return rent;
		}
		
	}
	
	class getOrerData implements RowDatas<CommonOrderEntity>{

		@Override
		public CommonOrderEntity getRowData(ResultSet rs) throws SQLException {
			CommonOrderEntity coe = new CommonOrderEntity();
		//	coe.setCo_id("co_id");
			coe.setCo_car_type(rs.getString("co_car_type"));
			coe.setCo_plan_pay_money(rs.getDouble("co_plan_pay_money"));
			coe.setCo_get_store(rs.getString("co_get_store"));
			coe.setCo_return_store(rs.getString("co_return_store"));
			coe.setCo_remark(rs.getString("co_remark"));
			coe.setCo_order_status(rs.getString("co_order_status"));
			coe.setCo_return_money(rs.getDouble("co_return_money"));
			return coe;
		}
		
	}
	
	class getMoneyData implements RowDatas<OrderMoney>{

		@Override
		public OrderMoney getRowData(ResultSet rs) throws SQLException {
			OrderMoney om = new OrderMoney();
			om.setOrder_rent_money(rs.getDouble("order_rent_money"));
			om.setOrder_car_damage_money(rs.getDouble("order_car_damage_money"));
			om.setOrder_guarantee_money(rs.getDouble("order_guarantee_money"));
			om.setOrder_insurance_money(rs.getDouble("order_insurance_money"));
			om.setOrder_service_money(rs.getDouble("order_service_money"));
			//om.setOrder_id(rs.getString("order_id"));
			return om;
		}
		
	}
	
	
}
